'use strict';

const { Controller } = require('egg');



class delController extends Controller {
  
  async delMes() {
    const { ctx } = this;
    let user_toekn = this.ctx.request.header.token;
    let decode = this.app.jwt.verify(user_toekn,this.app.config.jwt.secret);

    let deltitle =ctx.request.body.title;

    

    let userThree = await this.app.model.User.findAll({where:{username : decode}});
    if(userThree.length === 0){
      ctx.body = {
        code : 400,
      }
    }

    await this.app.model.Mes.destroy({where:{title : deltitle}});

      ctx.body = {
      code : 200,
    }
  }
    

  
}

module.exports = delController;
